<template>
  <div class="app-container">
    <div class="search-container">
      <el-form :model="searchParam" :inline="true">
        <el-form-item label="生产日期">
          <el-date-picker
            v-model="searchParam.planDateSearch"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="YYYY-MM-DD"
            @change="getplanDate"
          />
        </el-form-item>
        <el-form-item label="产品">
          <el-input
            v-model="searchParam.materialCode"
            placeholder="请输入产品"
            clearable
            @keyup.enter="search"
            readonly
            @click="showWorkOrderSelect"
          >
            <template #append>
              <el-button @click="resetMaterial"> 清除 </el-button>
            </template>
          </el-input>
        </el-form-item>
        <el-form-item label="计划状态">
          <el-select
            v-model="searchParam.formStatus"
            placeholder="请选择计划状态"
            clearable
          >
            <el-option
              v-for="item in useDictionary('ProduceOrderState')"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="班制" prop="shiftSystemId">
          <el-select
            v-model="searchParam.shiftSystemId"
            placeholder="请选择班制"
            @change="changeShiftSet"
            clearable
          >
            <el-option
              v-for="item in shiftSetList"
              :key="item.id"
              :label="item.shiftSetName"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="班次">
          <el-select
            v-model="searchParam.shiftId"
            placeholder="请输入计划班次"
            clearable
            style="width: 170px"
          >
            <el-option
              v-for="item in shiftList"
              :key="item.id"
              :label="item.shiftCode"
              :value="item.shiftId"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="search"
            ><i-ep-search />搜索</el-button
          >
          <el-button @click="resetNew"><i-ep-refresh />重置</el-button>
        </el-form-item>
      </el-form>
    </div>

    <el-card shadow="never" class="table-container">
      <template #header>
        <!--<el-button type="success" plain @click="openDialog()"
          ><i-ep-plus />新增</el-button
        >-->
        <el-button
          type="success"
          plain
          @click="approval()"
          :disabled="ids.length === 0"
          >审批</el-button
        >
        <el-button type="primary" plain @click="adjustOrder()"
          >生产顺序调整</el-button
        >
      </template>

      <el-table
        ref="dataTableRef"
        v-loading="loading"
        :data="tableData"
        highlight-current-row
        border
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          type="selection"
          width="55"
          align="center"
          :selectable="isConfirm"
        />
        <template v-for="item in tableColumns" :key="item">
          <TableColumn v-if="item.prop && item.isShow" :column="item">
            <template v-for="slot in Object.keys($slots)" #[slot]="scope">
              <slot :name="slot" v-bind="scope"></slot>
            </template>
          </TableColumn>
        </template>
        <!-- <el-table-column
          label="计划编号"
          prop="processingOrderNumber"
          min-width="180"
          show-overflow-tooltip
        />
        <el-table-column
          label="产品名称"
          prop="materialName"
          min-width="180"
          show-overflow-tooltip
        >
          <template #default="scope">
            {{ scope.row.materialName }}
          </template>
        </el-table-column>
        <el-table-column
          label="计划日期"
          prop="planDate"
          min-width="100"
          show-overflow-tooltip
          align="center"
          :formatter="formatDate"
        />
        <el-table-column
          label="砂芯编号"
          prop="sandCoreNumber"
          min-width="100"
        />

        <el-table-column
          label="冷芯/热芯"
          prop="coreState"
          min-width="100"
          align="center"
        />
        <el-table-column
          label="砂型号"
          prop="sandModel"
          min-width="200"
          align="left"
        />
        <el-table-column
          label="计划状态"
          prop="formStatus"
          min-width="100"
          align="center"
        >
          <template #default="scope">
            {{ useDictionary("ProduceOrderState", scope.row.formStatus) }}
          </template>
        </el-table-column>
        <el-table-column
          label="班次"
          prop="shiftName"
          min-width="100"
          show-overflow-tooltip
        />
        <el-table-column
          label="设备"
          prop="deviceName"
          min-width="100"
          show-overflow-tooltip
        />
        <el-table-column
          label="计划人员"
          prop="planUsers"
          min-width="130"
          show-overflow-tooltip
        />
        <el-table-column
          label="计划模数"
          prop="planQuantity"
          min-width="100"
          show-overflow-tooltip
          header-align="center"
          align="right"
        />
        <el-table-column
          label="总数量"
          prop="coreTotalQuantity"
          min-width="100"
          show-overflow-tooltip
          header-align="center"
          align="right"
        />
        <el-table-column
          label="合格数量"
          prop="validQuantity"
          min-width="100"
          show-overflow-tooltip
          header-align="center"
          align="right"
        />
        <el-table-column
          label="返修数量"
          prop="invalidQuantity"
          min-width="100"
          show-overflow-tooltip
          header-align="center"
          align="right"
        />
        <el-table-column
          label="报废数量"
          prop="scrapQuantity"
          min-width="100"
          show-overflow-tooltip
          header-align="center"
          align="right"
        />
        <el-table-column
          label="计划开始时间"
          prop="planBeginTime"
          min-width="160"
          sortable
          show-overflow-tooltip
          align="center"
        />
        <el-table-column
          label="计划结束时间"
          prop="planEndTime"
          min-width="160"
          show-overflow-tooltip
          align="center"
        />
        <el-table-column
          label="实际开始时间"
          prop="beginTime"
          min-width="160"
          show-overflow-tooltip
          align="center"
        />
        <el-table-column
          label="实际结束时间"
          prop="endTime"
          min-width="160"
          show-overflow-tooltip
          align="center"
        />
        <el-table-column
          label="创建时间"
          prop="createTime"
          min-width="160"
          show-overflow-tooltip
          align="center"
        />
        <el-table-column
          label="创建人"
          prop="createdUserName"
          min-width="100"
          show-overflow-tooltip
        /> -->
        <el-table-column fixed="right" label="操作" width="300" align="center">
          <template #default="scope">
            <el-button
              type="primary"
              size="small"
              link
              @click="approval(scope.row.id)"
              :disabled="scope.row.formStatus != 4"
            >
              审批
            </el-button>
            <!--<el-button
              type="primary"
              size="small"
              link
              @click="openDialog(scope.row)"
              ><i-ep-edit />编辑</el-button
            >
            <el-button
              type="primary"
              size="small"
              link
              @click="deleteItem(scope.row.id)"
              ><i-ep-delete />删除</el-button
            >-->
            <el-button
              type="primary"
              size="small"
              link
              @click="queryDialog(scope.row)"
            >
              查看报工
            </el-button>
            <el-button
              type="primary"
              size="small"
              link
              @click="queryCardDialog(scope.row)"
            >
              查看周转卡
            </el-button>
            <el-button
              type="primary"
              size="small"
              link
              @click="turnoverCardPrint(scope.row)"
            >
              周转卡打印
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-pagination
        :background="true"
        :current-page="pageable.pageNum"
        :page-size="pageable.pageSize"
        :page-sizes="[10, 25, 50, 100]"
        :total="pageable.total"
        layout="total, sizes, prev, pager, next, jumper"
        class="mt-[20px]"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-card>

    <mesplanworkingform-edit
      :visible="addDialog.visible"
      :title="addDialog.title"
      :data="addDialog.data"
      @reset-table="(id:string) => (id?.length ? getTableList() : reset())"
      :is-readonly="addDialog.readvisible"
      @change-visible="changeVisible"
    />
    <conten-select
      :visible="selectDialogSELECT.visible"
      @change-visible="changeVisibleSELECT"
      :plantId="searchParam.plantId"
      :brekList="brekList"
    />
    <produce-report-record-page
      :visible="reportDialog.visible"
      :title="reportDialog.title"
      :data="reportDialog.data"
      @reset-table="(id:string) => (id?.length ? getTableList() : reset())"
      :is-readonly="reportDialog.readvisible"
      @change-visible="changeVisibleReport"
    />
    <mesplanworkingform-adjustOrder
      :visible="adjustDialog.visible"
      :title="adjustDialog.title"
      :data="adjustDialog.data"
      @reset-table="(id:string) => (id?.length ? getTableList() : reset())"
      :is-readonly="adjustDialog.readvisible"
      @change-visible="changeVisibleAdjust"
    />
    <turnover-card-record-page
      :visible="cardDialog.visible"
      :title="cardDialog.title"
      :data="cardDialog.data"
      @reset-table="(id:string) => (id?.length ? getTableList() : reset())"
      :is-readonly="cardDialog.readvisible"
      @change-visible="changeVisibleCard"
    />
    <!--新周转卡打印-->
    <div style="height: 100vh; width: 100%" v-if="isPrint"></div>
    <div id="printBox_zhixin" v-if="isPrint">
      <div
        style="page-break-after: always"
        v-for="item in printData"
        :key="item?.id"
      >
        <div
          :id="`printId_${item?.id || ''}`"
          style="width: 350px; height: 350px"
        >
          <div
            style="
              font-size: 20px;
              display: flex;
              justify-content: center;
              margin-bottom: 20px;
              margin-top: 20px;
            "
            v-if="PRINT_TYPE == 1"
          >
            <canvas :id="`barcode_${item?.id || ''}`"></canvas>
          </div>
          <div v-else style="height: 20px"></div>
          <div
            style="
              font-size: 12px;
              font-weight: 600;
              word-break: break-all;
              width: 350px;
              margin-bottom: 10px;
            "
          >
            <span style="font-size: 18px; font-weight: 100"
              ><text style="font-size: 18px; font-weight: 600">{{
                item?.turnoverCode || ""
              }}</text></span
            >
          </div>
          <div style="font-size: 14px; margin-bottom: -10px; width: 350px">
            <span style="font-size: 18px; margin-right: 20px; font-weight: 600"
              >产品编号：&nbsp;<text
                style="font-size: 20px; font-weight: 600; margin-right: 20px"
                >{{ item?.materialCode || "" }}</text
              ></span
            >
          </div>
          <div style="font-size: 14px; margin-bottom: -10px; width: 350px">
            <br />
            <span style="font-size: 18px; margin-right: 20px; font-weight: 600"
              >图号：&nbsp;<text style="font-size: 20px; font-weight: 600">{{
                item?.figureNumber || ""
              }}</text></span
            >
          </div>
          <div style="font-size: 14px; margin-bottom: 0px; width: 350px">
            <br /><span
              style="font-size: 18px; margin-right: 10px; font-weight: 600"
              >生产批次：<text
                style="font-size: 20px; font-weight: 600; margin-right: 10px"
                >{{ item?.materialBatch || "" }}</text
              ></span
            >
          </div>
          <div style="height: 5px"></div>
          <div style="font-size: 12px; width: 350px; margin-bottom: 1px">
            <span style="font-size: 12px; margin-right: 20px; font-weight: 600"
              >打印时间：&nbsp;<text>{{ item?.createTime || "" }}</text></span
            >
            <span
              style="
                font-size: 12px;

                margin-right: 20px;
                font-weight: 600;
              "
              >打印人：&nbsp;<text
                >{{ item?.createdUserName || "" }}&nbsp;</text
              ></span
            >
          </div>
          <div style="height: 5px"></div>
          <div style="font-size: 14px; width: 400px; display: flex">
            <span
              style="
                flex: 1;

                font-size: 14px;
                margin-right: 20px;
                font-weight: 600;
              "
              >操作者1：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span
            >
            <span
              style="
                flex: 1;
                font-size: 14px;
                margin-right: 20px;
                font-weight: 600;
              "
              >操作者2：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span
            >
            <span
              style="
                flex: 1;

                font-size: 14px;
                margin-right: 20px;
                font-weight: 600;
              "
              >检&nbsp;查：&nbsp;&nbsp;&nbsp;&nbsp;</span
            >
          </div>
          <div
            style="
              font-size: 17px;
              margin-bottom: 0px;
              width: 300px;
              font-weight: 600;
            "
          ></div>
        </div>
      </div>
    </div>

    <!-- 列设置 -->
    <ColSetting
      v-model:col-setting="tableColumns"
      v-model:search-setting="searchColumns"
      @search-handle="(e:boolean) => (showSearch = e)"
    />
  </div>
</template>

<script setup lang="tsx">
import { useTable, useDownload, useDictionary } from "@/utils/useTable";
import request from "@/utils/request";
import { getLodop } from "@/utils/LocalLodopFuncs";
// import { RootObject } from "@/views/demo/iframePrintReturnUnitOne/index";
import printJS from "print-js";
import QRCode from "qrcode";

const PRINT_TYPE = import.meta.env.VITE_APP_PRINT_TYPE;

defineOptions({
  name: "MESMESPLANWORKINGFORM",
  inheritAttrs: false,
});

// 请求参数
const requestApi = "/mes/mesplanworkingform/queryByPage";

// 是否需要分页
const pagination = true;

const initParam = {};

// 初始化搜索参数数据
const searchParamInit = {
  materialId: "",
  materialCode: "",
  formStatus: "",
  shiftId: "",
  shiftSystemId: "",
  planDateSearch: [],
  planDateStart: "",
  planDateEnd: "",
  //制芯1 冷铁2
  processesClassification: "1",
};

const deleteParam = {
  api: "/mes/mesplanworkingform/delete",
  data: {},
};

// 数据请求错误后处理
function requestError() {}

const dataCallBack = ref(undefined); // 无需二次数据处理&不传赞数也行

// 表格操作 Hooks
const {
  tableData,
  pageable,
  searchParam,
  ids,
  getTableList,
  search,
  reset,
  handleSizeChange,
  handleCurrentChange,
  handleSelectionChange,
  handleTableDelete,
  loading,
}: any = useTable(
  requestApi,
  initParam,
  searchParamInit,
  pagination,
  dataCallBack.value,
  requestError,
  deleteParam
);

onMounted(() => {
  getTableList();
  getShiftSetList();
});

const addDialog = reactive<DialogOption>({
  visible: false,
  readvisible: false,
  title: "",
  data: {},
});
const adjustDialog = reactive<DialogOption>({
  visible: false,
  readvisible: false,
  title: "",
  data: {},
});
// 查询详情
async function getInfo(id: string) {
  request({
    url: `/mes/mesplanworkingform/get/${id}`,
    method: "get",
  })
    .then((data) => {
      addDialog.data = data.data;
      addDialog.visible = true;
    })
    .catch((res) => {
      console.log(res);
    });
}

/** 打开工单表表单弹窗 */
function openDialog(roleObj?: Object) {
  if (roleObj) {
    addDialog.title = "修改工单表";
    getInfo(roleObj.id);
  } else {
    addDialog.title = "新增工单表";
    addDialog.visible = true;
  }
  addDialog.readvisible = false;
}

/** 打开工单表表单弹窗 详情 */
function openDialogdetail(roleObj?: any) {
  addDialog.title = "工单表详情";
  getInfo(roleObj.id);
  addDialog.readvisible = true;
}

function changeVisible(value: boolean) {
  addDialog.visible = value;
  if (!value) {
    addDialog.data = {};
  }
}
/** 打开生产顺序调整弹窗 */
function adjustOrder() {
  adjustDialog.title = "生产顺序调整";
  adjustDialog.visible = true;
  adjustDialog.readvisible = false;
}

function changeVisibleAdjust(value: boolean) {
  adjustDialog.visible = value;
  if (!value) {
    adjustDialog.data = {};
  }
}
function getplanDate(data: any) {
  if (data) {
    searchParam.value.planDateStart = data[0];
    searchParam.value.planDateEnd = data[1];
  } else {
    searchParam.value.planDateStart = "";
    searchParam.value.planDateEnd = "";
  }
}

async function deleteItem(id: any) {
  ElMessageBox.confirm("确认删除已选中的数据项?", "警告", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  }).then(async () => {
    const { data } = await request({
      url: `/mes/mesplanworkingform/deleteItem/${id}`,
      method: "post",
    });
    search();
  });
}
//时间格式处理，yyyy-mm-dd
function formatDate(row, column) {
  const date = row[column.property];
  if (!date) return "";
  return date.split(" ")[0]; // 返回日期的年月日部分，而隐藏时间部分
}
const showWorkOrderSelect = () => {
  selectDialogSELECT.value.visible = true;
};
//选择物料弹窗
const selectDialogSELECT = ref({
  visible: false,
});
const changeVisibleSELECT = (val: boolean, data: any) => {
  selectDialogSELECT.value.visible = val;
  if (data) {
    searchParam.value.materialId = data.id;
    searchParam.value.materialCode = data.materialCode;
  }
};
// 回显的数据
const brekList = ref([]);
const resetMaterial = () => {
  searchParam.value.materialId = "";
  searchParam.value.materialCode = "";
};
//班制
const shiftSetList = ref([]);
async function getShiftSetList() {
  await request({
    url: "mes/messhiftset/getList",
    method: "post",
    data: { plantId: searchParam.plantId, enabled: 1 },
  }).then((res) => {
    shiftSetList.value = res.data;
  });
}
function changeShiftSet(val) {
  searchParam.value.shiftSystemId = val;
  searchParam.value.shiftId = "";
  shiftList.value = [];
  if (val) {
    getShifts();
  }
}
//班次
const shiftList = ref([]);
async function getShifts() {
  await request({
    url: "mes/messhiftset/getDetails",
    method: "post",
    data: {
      id: searchParam.value.shiftSystemId,
    },
  }).then((res) => {
    shiftList.value = res.data;
  });
}
const resetNew = () => {
  searchParam.value.materialId = "";
  searchParam.value.materialCode = "";
  searchParam.value.formStatus = "";
  searchParam.value.shiftSystemId = "";
  searchParam.value.shiftId = "";
  searchParam.value.planDateSearch = "";
  searchParam.value.planDateStart = "";
  searchParam.value.planDateEnd = "";
  searchParam.value.processesClassification = "1";
  shiftList.value = [];
  search();
};
async function approval(id: any) {
  if (id) {
    ids.value = [id];
  }
  ElMessageBox.confirm("是否确定对已选数据进行审批?", "警告", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  }).then(async () => {
    const res = await request({
      url: `/mes/mesplanworkingform/approval`,
      method: "post",
      data: { ids: ids.value },
    });
    if (res.code == 200) {
      ElMessage({
        type: "success",
        message: "审批成功",
      });
      search();
    }
  });
}
const isConfirm = (row: { formStatus: number }, index: number) => {
  return row.formStatus === 4;
};
function printNumber(value: any) {
  if (!value) {
    return "请输入数字";
  } else if (isNaN(parseFloat(value)) && isFinite(value)) {
    return "请输入数字";
  } else if (!/^[0-9]+$/.test(value)) {
    return "请输入数字";
  } else if (Number(value) <= 0) {
    return "请输入大于0的值";
  } else {
    return true;
  }
}
const reportDialog = reactive<DialogOption>({
  visible: false,
  readvisible: false,
  title: "",
  data: {},
});
async function queryDialog(row: any) {
  reportDialog.title = "查看报工";
  reportDialog.data = row;
  reportDialog.visible = true;
}
function changeVisibleReport(value: boolean) {
  reportDialog.visible = value;
  if (!value) {
    reportDialog.data = {};
  }
}
const cardDialog = reactive<DialogOption>({
  visible: false,
  readvisible: false,
  title: "",
  data: {},
});
async function queryCardDialog(row: any) {
  cardDialog.title = "查看周转卡";
  cardDialog.data = row;
  cardDialog.visible = true;
}
function changeVisibleCard(value: boolean) {
  cardDialog.visible = value;
  if (!value) {
    cardDialog.data = {};
  }
}

const isPrint = ref(false);

async function printFun1(pitem: any) {
  const qrCodeId = `barcode_${pitem?.id || ""}`;
  const qrCodeElement = document.getElementById(qrCodeId);

  if (qrCodeElement) {
    try {
      await QRCode.toCanvas(qrCodeElement, pitem.turnoverCode || "", {
        width: 135, // 可以根据需要调整二维码的大小
        margin: 1, // 可以根据需要调整二维码的边距
      });
    } catch (err) {
      console.error("Error generating QR code:", err);
    }
  }
}

//周转卡打印
function turnoverCardPrint(row: any) {
  ElMessageBox.prompt(`请输入打印次数`, "打印", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    dangerouslyUseHTMLString: true,
    inputValidator: (value: string) => printNumber(value),
    beforeClose: (action, instance, done) => {
      if (action === "confirm") {
        // 开启按钮加载
        instance.confirmButtonLoading = true;
        isPrint.value = true;
        row.counts = instance.inputValue;
        getPrintData(row);
        setTimeout(() => {
          done();
        }, 500);
        done();
      } else {
        done();
      }
    },
  }).catch(() => {});
}
// 打印数据，数组形式
const printData = ref<any[]>([]);
async function getPrintData(row: any) {
  const { data } = await request({
    url: `/mes/mesturnovercard/prints`,
    method: "post",
    data: { counts: row.counts, mesPlanWorkingForm: row },
  }).finally(() => {});
  printData.value = data;

  if (PRINT_TYPE == 1) {
    nextTick(() => {
      printData.value?.map((e) => {
        printFun1(e);
      });
    });
    setTimeout(() => {
      printJS({
        printable: "printBox_zhixin", // id
        type: "html", //打印类型
        scanStyles: false,
        style:
          "@media print { @page { margin: 0mm; } body { margin: 0;display: flex;justify-content: center; } .page { page-break-after: always; } }",
      });
      isPrint.value = false;
    }, 500);
  } else {
    setTimeout(() => {
      let LODOP = getLodop();
      LODOP.PRINT_INIT(`周转卡打印-${printData.value[0].turnoverCode}`);
      printData.value?.map((e) => {
        printFun2(e, LODOP);
      });
      //LODOP.PRINT(); // 打印
      console.log(LODOP.Printers.list);
      LODOP.PREVIEW(); // 预览
      isPrint.value = false;
      window.parent.postMessage("打印中，请稍后...", "*");
    }, 1000);
  }
}

function printFun2(pitem: any, LODOP: any) {
  LODOP.SET_PRINT_PAGESIZE(1, "100mm", "100mm", ""); // 设置纸张类型（方向、宽度、高度、纸张类型名称）
  LODOP.ADD_PRINT_HTM(
    "38mm",
    "3mm",
    "100mm",
    "100mm",
    document.getElementById(`printId_${pitem?.id || ""}`)?.innerHTML
  );
  LODOP.ADD_PRINT_BARCODE(
    "5mm",
    "30mm",
    "40mm",
    "40mm",
    "QRCode",
    pitem?.turnoverCode || ""
  );
  LODOP.NEWPAGE(); //另起一页
}

// -----------新周转卡打印---------------

const tableColumns = reactive([
  {
    prop: "processingOrderNumber",
    label: "计划编号",
    minWidth: 180,
    isShow: true,
    align: "left",
  },
  {
    prop: "materialName",
    label: "产品名称",
    minWidth: 180,
    isShow: true,
    align: "left",
  },
  {
    prop: "planDate",
    label: "计划日期",
    minWidth: 100,
    isShow: true,
    align: "center",
    formatter: formatDate,
  },
  {
    prop: "sandCoreNumber",
    label: "砂芯编号",
    minWidth: 100,
    isShow: true,
    align: "left",
  },
  {
    prop: "coreState",
    label: "冷芯/热芯",
    minWidth: 100,
    isShow: true,
    align: "center",
  },
  {
    prop: "sandModel",
    label: "砂型号",
    minWidth: 200,
    isShow: true,
    align: "left",
  },
  {
    prop: "formStatus",
    label: "计划状态",
    minWidth: 100,
    isShow: true,
    align: "center",
    render: (scope: any) =>
      useDictionary("ProduceOrderState", scope.row.formStatus),
  },
  {
    prop: "shiftName",
    label: "班次",
    minWidth: 100,
    isShow: true,
    align: "left",
  },
  {
    prop: "deviceName",
    label: "设备",
    minWidth: 100,
    isShow: true,
    align: "left",
  },
  {
    prop: "planUsers",
    label: "计划人员",
    minWidth: 130,
    isShow: true,
    align: "left",
  },
  {
    prop: "planQuantity",
    label: "计划模数",
    minWidth: 100,
    isShow: true,
    align: "right",
    headerAlign: "center",
  },
  {
    prop: "coreTotalQuantity",
    label: "总数量",
    minWidth: 100,
    isShow: true,
    align: "right",
    headerAlign: "center",
  },
  {
    prop: "validQuantity",
    label: "合格数量",
    minWidth: 100,
    isShow: true,
    align: "right",
    headerAlign: "center",
  },
  {
    prop: "invalidQuantity",
    label: "返修数量",
    minWidth: 100,
    isShow: true,
    align: "right",
    headerAlign: "center",
  },
  {
    prop: "scrapQuantity",
    label: "报废数量",
    minWidth: 100,
    isShow: true,
    align: "right",
    headerAlign: "center",
  },
  {
    prop: "planBeginTime",
    label: "计划开始时间",
    minWidth: 160,
    isShow: true,
    align: "center",
    sortable: true,
  },
  {
    prop: "planEndTime",
    label: "计划结束时间",
    minWidth: 160,
    isShow: true,
    align: "center",
  },
  {
    prop: "beginTime",
    label: "实际开始时间",
    minWidth: 160,
    isShow: true,
    align: "center",
  },
  {
    prop: "endTime",
    label: "实际结束时间",
    minWidth: 160,
    isShow: true,
    align: "center",
  },
  {
    prop: "createTime",
    label: "创建时间",
    minWidth: 160,
    isShow: true,
    align: "center",
  },
  {
    prop: "createdUserName",
    label: "创建人",
    minWidth: 100,
    isShow: true,
    align: "left",
  },
]);

//  render: (scope: any) =>
//       scope.row.repairLevel == "1" && scope.row.repairLevel * 1 < 4 ? (
//         <el-tag type="danger">
//           {useDictionary("EamFaultLevel", scope.row.repairLevel)}
//         </el-tag>
//       ) : scope.row.repairStatus * 1 >= 4 ? (
//         <el-tag type="info" type="success">
//           {useDictionary("EamFaultLevel", scope.row.repairLevel)}
//         </el-tag>
//       ) : scope.row.repairLevel !== "1" && scope.row.repairStatus * 1 < 4 ? (
//         <el-tag>{useDictionary("EamFaultLevel", scope.row.repairLevel)}</el-tag>
//       ) : (
//         <div></div>
//       ),
const searchColumns = ref([]);
</script>
